<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <!-- 导入基础样式 -->
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/register.css">
  <script src="../js/register.js"></script>
  <!-- 必须先引入jquery的js -->
  <script type="text/javascript" src="../js/jquery.min.js"></script>
</head>

<body>
<div class="container">
  <form id="registerFrom" method="post" >
    <h2>新用户注册</h2>
    <div class="item">用户名称：<input type="text" name="username" id="username" required></div>
    <div class="item">设置密码：<input type="password" name="password" id="password" required></div>
    <div class="item">确认密码：<input type="password" name="again_password" id="again_password" required></div>
    <div class="button">
      <input type="button" value="确认" onclick="register()">
      <input type="reset" value="重置" id="reset">
    </div>
  </form>
</div>
<script>
  function register(){
    $.ajax({
      url:"/hotel/register",
      type:"post",
      data:$("#registerFrom").serialize(),//序列化传值作用
      success:function(data){
        if(data == "注册成功"){
          alert(data);
          window.location.href = 'login.html';
        }else{
         alert(data);
        }
      }
    })
  }

</script>
</body>
</html>